import 'package:flutter_kit_dsp/flutter_kit_dsp.dart';

class MyEqController extends EqController {
  RxBool add_touch = false.obs;
  RxBool sub_touch = false.obs;
  @override
  void onInit() {
    super.onInit();
  }

  void chooseGroup(int index) {
    globalController.chooseGroup(groupList, groupList[index], 'EQ');
  }

  void chooseChInGroup(ChannelModel ch) {
    final group = groupList.firstWhereOrNull(($0) => $0.ch1!.name == ch.name || $0.ch2!.name == ch.name);
    if (group == null) return;
    globalController.chooseChInGroup(groupList, group, ch, 'EQ');
  }

  void updateSignGain(bool isadd) {
    final sign = globalController.rxModel.value.current_ch.sign_list.firstWhereOrNull(($0) => $0.select);
    if (sign == null) return;
    final value = isadd ? sign.gain + 0.1 : sign.gain - 0.1;
    globalController.updateSignGain(sign, value, isSend: true);
  }

  void touchAddSub(int index, bool began) {
    index == 0 ? add_touch.value = began : sub_touch.value = began;
  }
}
